local skel = fk.CreateSkill {
  name = "emo__chaosheng",
  tags = {Skill.Limited},
}

Fk:loadTranslationTable{
  ["emo__chaosheng"] = "潮生",
  [":emo__chaosheng"] = "限定技，出牌阶段开始时，你可以扣减一点体力上限，令对所有其他角色各造成一点雷电伤害，然后令一名角色重置武将牌上的限定技。",

  ["#emo__chaosheng-choose"] = "潮生：令一名角色重置武将牌上的限定技",

  ["$emo__chaosheng1"] = "涟漪荡漾，歌声闪亮。",
  ["$emo__chaosheng2"] = "跳跃旋转，碧波闪闪。",
}

skel:addEffect(fk.EventPhaseStart, {
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.phase == Player.Play
    and player:usedSkillTimes(skel.name, Player.HistoryGame) == 0
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    for _, to in pairs(room:getOtherPlayers(player)) do
      room:damage { from = player, to = to, damage = 1, skillName = skel.name, damageType = fk.ThunderDamage }
    end
    if player.dead then return end
    local tos = room:askToChoosePlayers(player, {
      targets = room.alive_players, min_num = 1, max_num = 1, skill_name = skel.name, cancelable = false,
      prompt = "#emo__chaosheng-choose"
    })
    if #tos == 0 then return end
    local to = tos[1]
    for _, g in ipairs({to.general, to.deputyGeneral}) do
      local general = Fk.generals[g]
      if general then
        for _, skill in ipairs(general:getSkillNameList(true)) do
          local s = Fk.skills[skill]
          if s:hasTag(Skill.Limited) then
            to:setSkillUseHistory(skill, 0, Player.HistoryGame)
          end
        end
      end
    end
  end,
})

return skel
